package
{
	import BasicEntity.DrawTool;
	import BasicEntity.GameWorld;
	import BasicEntity.Test;
	import BasicEntity.Vector2D;
	import BasicEntity.Vehicle;
	import BasicEntity.WanderRadar;
	import flash.display.CapsStyle;
	import flash.display.LineScaleMode;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	import flash.geom.Matrix;
	import flash.geom.Point;
	import flash.system.IME;
	import flash.utils.Dictionary;
	
	public class AIEntity extends Sprite
	{
		private var child:Sprite = new Sprite();
        private var bgColor:uint = 0x00CCFF;
		
		public static var wander:WanderRadar;
       
		public function AIEntity()
		{
			Init();	
			DrawLayout();
			
			
			
			//var m:Matrix = new Matrix();
			//m.a = 60;
			//m.b = 40;
			//
			//var mc:Matrix = new Matrix();
			//mc.a = 60;
			//mc.b = 40;
			//graphics.drawCircle(mc.a+400, mc.b+300, 3);
			//graphics.beginFill(0xff0000, 1);
			//m.rotate(45);
			//m.translate(10, 4);
			//
			//
			//var angle:Number = 100;
			//var a:Number = angle * Math.PI / 180;
			//var r:Matrix = new Matrix(Math.cos(a), Math.sin(a), -Math.sin(a), Math.cos(a), 400, 300);
			//trace(m);
			 //m.concat(r);
			//
			//trace(Math.atan(m.a / m.b));
			//trace(Math.acos(m.d));
			//trace(r);
			//trace(m);
			//
			//var vv:Vector2D = new Vector2D(m.a, m.b);
			//trace(vv.Angle);
			//trace(vv.Angle * 180 / Math.PI);
			//
			//
			//graphics.drawCircle(m.a+m.tx, m.b+m.ty, 3);
			//graphics.beginFill(0x00ff00, 1);
			//
			//var v1:Vector2D = new Vector2D(100 - 400, 100 - 300);
			//var v2:Vector2D = new Vector2D(m.a - 400, m.b - 300);
			//trace((Math.acos(v1.Normalize().DotProduct(v2.Normalize()))) );
		}
		
		public function Test():void
		{
			var v1:Vector2D = new Vector2D(50, 50);
			v1.Angle =  70 * Math.PI / 180.0;
			v1.DrawVector(graphics, 0xff0000, 400, 300);
			
			var v2:Vector2D = new Vector2D(45, 45);
			v2.Angle =  45 * Math.PI / 180.0;
			v2.DrawVector(graphics, 0x00ff00, 400, 300);
			
			var v3:Vector2D = v1.Subtract(v2);
			v3.DrawVector(graphics, 0x0000ff, v2.X + 400, v2.Y + 300);
			
					
			var p1:int = 60;
			var p2:int = 0;
			
			DrawTool.DrawPoint(graphics, 0x0000ff, p1 + 400, p2 + 300);
			
			var v4:Vector2D = new Vector2D(p1, p2);
		}
		
		
		public function DrawLayout():void
		{
			var vx:Vector2D = new Vector2D(800, 0);
			vx.DrawVector(graphics, 0, 0, 300);
			var vy:Vector2D = new Vector2D(0, 600);
			vy.DrawVector(graphics, 0, 400, 0);
		}
		
		
		public function Init():void
		{		
			IME.enabled = false;
			
			this.stage.addEventListener(KeyboardEvent.KEY_DOWN, function(e:KeyboardEvent):void
			{
				GameWorld.InputKey(e.keyCode);
				trace(e.keyCode);
			}); 
			this.stage.addEventListener(KeyboardEvent.KEY_UP, function(e:KeyboardEvent):void
			{
				
			}); 
			GameWorld.Init(this,graphics);	
		}
		
		
		
		
	}
}